Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opkg module: allow installing a package in a certain version #5688

Merged

Conversation

joergho
Copy link
Contributor

@joergho joergho commented Dec 15, 2022

SUMMARY

This extends the community.general.opkg module. It additionally allows to install a package in a certain version.

Tested with opkg 0.4.2 on NI Linux Real-Time 8.8

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

community.general.opkg module

ADDITIONAL INFORMATION

opkg module: allow NAME=VERSION syntax to install a package in a certain version

example:

- name: Install foo in version 1.2
  community.general.opkg:
    name: foo=1.2
    state: present

@ansibullbot
Copy link
Collaborator

cc @skinp
click here for bot help

@ansibullbot ansibullbot added feature This issue/PR relates to a feature request module module new_contributor Help guide this first time contributor os packaging plugins plugin (any type) labels Dec 15, 2022
@joergho joergho force-pushed the opkg_name_version_syntax branch from f8d7fab to 3b06754 Compare December 15, 2022 12:28
@joergho joergho changed the title opkg module: allow NAME=VERSION syntax opkg module: allow installing a package in a certain version Dec 15, 2022
@joergho joergho force-pushed the opkg_name_version_syntax branch from 3b06754 to 787796c Compare December 15, 2022 12:31
@github-actions
Copy link

github-actions bot commented Dec 15, 2022

Docs Build 📝

Thank you for contribution!✨

This PR has been merged and your docs changes will be incorporated when they are next published.

@ansibullbot

This comment was marked as outdated.

@ansibullbot ansibullbot added ci_verified Push fixes to PR branch to re-run CI needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Dec 15, 2022
@joergho joergho force-pushed the opkg_name_version_syntax branch from 308a181 to 1eeeaca Compare December 15, 2022 13:24
@ansibullbot ansibullbot removed ci_verified Push fixes to PR branch to re-run CI needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Dec 15, 2022
@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-6 labels Dec 15, 2022
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! I've added some first comments.

plugins/modules/opkg.py Outdated Show resolved Hide resolved
plugins/modules/opkg.py Outdated Show resolved Hide resolved
plugins/modules/opkg.py Outdated Show resolved Hide resolved
plugins/modules/opkg.py Outdated Show resolved Hide resolved
plugins/modules/opkg.py Outdated Show resolved Hide resolved
plugins/modules/opkg.py Outdated Show resolved Hide resolved
plugins/modules/opkg.py Outdated Show resolved Hide resolved
@joergho joergho force-pushed the opkg_name_version_syntax branch from 1eeeaca to 5bd3977 Compare December 16, 2022 09:49
@joergho
Copy link
Contributor Author

joergho commented Dec 16, 2022

@felixfontein
Thanks for your review. I addressed all your review comments.

I also noticed that there was a bug that parameter force=reinstall would not actually reinstall a package if it was already installed. I introduced a fix for this: 5bd3977

@felixfontein
Copy link
Collaborator

Could you please move the bugfix to a new PR so we can backport it also to stable-5? Thanks.

@joergho
Copy link
Contributor Author

joergho commented Dec 19, 2022

Could you please move the bugfix to a new PR so we can backport it also to stable-5? Thanks.

Sure. See PR #5705

Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me (looking at the code; I cannot test it). Now there is a conflict that needs to be resolved though (please rebase).

@ansibullbot ansibullbot removed the new_contributor Help guide this first time contributor label Dec 19, 2022
@ansibullbot ansibullbot added needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Dec 19, 2022
example:
- name: Install foo in version 1.2
  community.general.opkg:
    name: foo=1.2
    state: present

Signed-off-by: Joerg Hofrichter <joerg.hofrichter@ni.com>
Signed-off-by: Joerg Hofrichter <joerg.hofrichter@ni.com>
@joergho joergho force-pushed the opkg_name_version_syntax branch from ccdd57b to 5232803 Compare December 20, 2022 07:06
@ansibullbot ansibullbot removed needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Dec 20, 2022
@joergho
Copy link
Contributor Author

joergho commented Dec 20, 2022

Looks good to me (looking at the code; I cannot test it). Now there is a conflict that needs to be resolved though (please rebase).

Rebased in 5232803

Also I executed a test with python3.10 and opkg 0.4.2 on NI Linux Real-Time 8.8:

opkg-tests.yml:

- name: "opkg tests"
  gather_facts: no

  tasks:
  - name: "opkg remove (1)"
    community.general.opkg:
        name: "tmux"
        state: "absent"

  - name: "opkg remove (2)"
    community.general.opkg:
        name: "tmux"
        state: "absent"

  - name: "opkg install (1)"
    community.general.opkg:
        name: "tmux"
        state: "present"

  - name: "opkg install (2)"
    community.general.opkg:
        name: "tmux"
        state: "present"

  - name: "install --force-reinstall"
    community.general.opkg:
        name: "tmux"
        state: "present"
        force: "reinstall"

  - name: "opkg remove (3)"
    community.general.opkg:
        name: "tmux"
        state: "absent"

  - name: "opkg install with version"
    community.general.opkg:
        name: "tmux=2.6-r0.18"
        state: "present"

  - name: "opkg install with incorrect version"
    community.general.opkg:
        name: "tmux=2.6"
        state: "present"

$ ansible-playbook opkg-tests.yml

PLAY [opkg tests] **************************************************************************************************************************

TASK [opkg remove (1)] **************************************************************************************************************************
changed: [agent01]

TASK [opkg remove (2)] **************************************************************************************************************************
ok: [agent01]

TASK [opkg install (1)] **************************************************************************************************************************
changed: [agent01]

TASK [opkg install (2)] **************************************************************************************************************************
ok: [agent01]

TASK [install --force-reinstall] **************************************************************************************************************************
changed: [agent01]

TASK [opkg remove (3)] **************************************************************************************************************************
changed: [agent01]

TASK [opkg install with version] **************************************************************************************************************************
changed: [agent01]

TASK [opkg install with incorrect version] **************************************************************************************************************************
fatal: [agent01]: FAILED! => {"changed": false, "msg": "failed to install tmux=2.6: No packages installed or removed.\n"}

PLAY RECAP **************************************************************************************************************************
agent01 : ok=7 changed=5 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

@felixfontein
Copy link
Collaborator

Thanks for testing it! :) I'll keep this open a few more days and will then merge it if nobody objects until then.

@felixfontein
Copy link
Collaborator

Merging so that #5718 can rebase and advance.

@felixfontein felixfontein merged commit b3485b8 into ansible-collections:main Dec 22, 2022
@patchback
Copy link

patchback bot commented Dec 22, 2022

Backport to stable-6: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-6/b3485b8fcab59e47d7460c3473329a9d516c3ea0/pr-5688

Backported as #5724

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Dec 22, 2022
* opkg: allow installing a package in a certain version

example:
- name: Install foo in version 1.2
  community.general.opkg:
    name: foo=1.2
    state: present

Signed-off-by: Joerg Hofrichter <joerg.hofrichter@ni.com>

* opkg: use list for passing arguments to run_command

Signed-off-by: Joerg Hofrichter <joerg.hofrichter@ni.com>

Signed-off-by: Joerg Hofrichter <joerg.hofrichter@ni.com>
(cherry picked from commit b3485b8)
@felixfontein
Copy link
Collaborator

@joergho thanks for contributing this!

@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Dec 22, 2022
felixfontein pushed a commit that referenced this pull request Dec 22, 2022
…a package in a certain version (#5724)

opkg module: allow installing a package in a certain version  (#5688)

* opkg: allow installing a package in a certain version

example:
- name: Install foo in version 1.2
  community.general.opkg:
    name: foo=1.2
    state: present

Signed-off-by: Joerg Hofrichter <joerg.hofrichter@ni.com>

* opkg: use list for passing arguments to run_command

Signed-off-by: Joerg Hofrichter <joerg.hofrichter@ni.com>

Signed-off-by: Joerg Hofrichter <joerg.hofrichter@ni.com>
(cherry picked from commit b3485b8)

Co-authored-by: joergho <48011876+joergho@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue/PR relates to a feature request module module os packaging plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants